package com.hu.zhcc.shiro.service.dingming;

import com.hu.zhcc.common.entity.Page;
import com.hu.zhcc.common.entity.PageRequest;
import com.hu.zhcc.shiro.dao.dingming.TSetmealMapper;
import com.hu.zhcc.shiro.entity.dingming.TSetmeal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class TSetmealServiceImpl implements TSetmealService{
    @Autowired
    private TSetmealMapper tSetmealMapper;
    
    @Override
    public int deleteByPrimaryKey(Integer id) {
        return tSetmealMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(TSetmeal record) {
        return tSetmealMapper.insert(record);
    }

    @Override
    public int insertSelective(TSetmeal record) {
        return tSetmealMapper.insertSelective(record);
    }

    @Override
    public TSetmeal selectByPrimaryKey(Integer id) {
        return tSetmealMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(TSetmeal record) {
        return tSetmealMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(TSetmeal record) {
        return tSetmealMapper.updateByPrimaryKey(record);
    }

    @Override
    public Page<TSetmeal> listTSetmeal(Map<String, Object> parameters, Integer offset, Integer limit) {
        int total = tSetmealMapper.countTSetmeal(parameters);
        if(limit==null){
            limit=total;
        }
        if(offset==null){
            offset=0;
        }
        List<TSetmeal> tSetmealList = null;
        if (total > 0) {
            PageRequest pageRequest = new PageRequest(offset, limit, parameters);
            tSetmealList = tSetmealMapper.listTSetmeal(pageRequest);
        }
        return new Page<TSetmeal>(total, tSetmealList);
    }
}
